﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class folltank : MonoBehaviour {

    public Transform play1;
    public Transform play2;
    private Camera camera;

    private Vector3 offset;//偏移

	void Start () {
       //偏移 = 当前相机位置-（坦克1+坦克2）/2
        offset = transform.position - (play1.position + play2.position) / 2;

        camera = this.GetComponent<Camera>();
	}
	
	
	void Update () {
        if (play1 == null || play2 == null) return;

        transform.position = (play1.position + play2.position) / 2 + offset;

        float distance = Vector3.Distance(play1.position, play2.position);
        float size = distance * 1f;
        camera.orthographicSize = size;
	}
}
